using System.Threading;
using System.Threading.Tasks;
using MediatR;
using B.S.BasicData.EroorCode;
using B.S.BasicData.Domain;
using B.S.BasicData.Infrature;
using System.Collections.Generic;

public class ProductNameListHandler : IRequestHandler<ProductNameListRequest, ApiResult<List<ProductName>>>
{
    private readonly IBaseRepository<ProductName> _repository;
    public ProductNameListHandler(IBaseRepository<ProductName> repository)
    {
        _repository = repository;
    }

    public async Task<ApiResult<List<ProductName>>> Handle(ProductNameListRequest request, CancellationToken cancellationToken)
    {
        var list = await _repository.GetAllAsync();
        return ApiResult<List<ProductName>>.Success(new List<ProductName>(list));
    }
} 